import { createRouter, createWebHistory } from 'vue-router'

import IndexView from '@/views/index/index.vue'
import ClazzView from '@/views/clazz/index.vue'
import StuView from '@/views/stu/index.vue'
import DeptView from '@/views/dept/index.vue'
import EmpView from '@/views/emp/index.vue'
import EmpReportView from '@/views/report/emp/index.vue'
import StuReportView from '@/views/report/stu/index.vue'
import LogView from '@/views/log/index.vue'
import LoginView from '@/views/login/index.vue'
import LayoutView from '@/views/layout/index.vue'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      // 例如：当/index匹配成功，IndexView将被渲染到layout的 <router-view> 内部
      path: '/',
      // name: '',
      component: LayoutView,
      // 当页面访问的是'/'时，例如刷新时http://localhost:5173/，会重定向到index页面
      redirect: '/index',
      children: [
        {path: 'index',name: 'index',component: IndexView},
        {path: 'clazzs',name: 'clazzs',component: ClazzView},
        {path: 'students',name: 'students',component: StuView},
        {path: 'depts',name: 'depts',component: DeptView},
        {path: 'emps',name: 'emps',component: EmpView},
        {path: 'empReport',name: 'empReport',component: EmpReportView},
        {path: 'stuReport',name: 'stuReport',component: StuReportView},
        {path: 'log',name: 'log',component: LogView},
        {path: 'login',name: 'login',component: LoginView}
      ]
    },
    // 如果上部的路由配置都不匹配，那么就会匹配到这里，而LoginView会之间渲染展示到App.vue的<router-view>中
    {path: '/login',name: 'login',component: LoginView}
  ]
})

export default router